home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 September & October / Amiga-CD 1996 #9-10.iso / demos / storm-c / stormwizard / example-source / c-source / palette / palette.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-19  |  6.4 KB  |  223 lines

  1. /* Demonstration der Einbindung "Wizardfremder" Gadgets.
  2.  
  3.    (geschrieben unter StormC V1.1)
  4.  
  5.    $VER:              1.0 (12.06.96)
  6.  
  7.    Autor:             Thomas Mittelsdorf
  8.  
  9.    © 1996 HAAGE & PARTNER Computer GmbH,  All Rights Reserved
  10.  
  11. */
  12.  
  13. #include    <stdio.h>
  14. #include    <stdlib.h>
  15. #include    <string.h>
  16.  
  17. #include    <clib/alib_protos.h>
  18. #include    <pragma/dos_lib.h>
  19. #include    <pragma/exec_lib.h>
  20. #include    <pragma/graphics_lib.h>
  21. #include    <pragma/intuition_lib.h>
  22. #include    <pragma/utility_lib.h>
  23. #include    <pragma/wizard_lib.h>
  24.  
  25. #include    <exec/exec.h>
  26. #include    <exec/memory.h>
  27. #include    <gadgets/colorwheel.h>
  28. #include    <gadgets/gradientslider.h>
  29. #include    <intuition/gadgetclass.h>
  30. #include    <intuition/intuition.h>
  31. #include    <utility/utility.h>
  32. #include    <libraries/wizard.h>
  33.  
  34. struct Library *UtilityBase;
  35. struct Library *WizardBase;
  36. struct Library *ColorWheelBase;
  37.  
  38. APTR    MySurface;
  39. struct Screen *MyScreen;
  40. struct DrawInfo *MyDrInfo;
  41.  
  42. struct WizardWindowHandle *MyWinHandle;
  43. struct NewWindow *MyNewWindow;
  44. struct Window *MyWindow;
  45.  
  46. struct Gadget *MyGadgets[40];
  47.  
  48. struct Gadget *MyColorWheel;
  49.  
  50. struct TextAttr MyTextAttr=
  51. {
  52.     "topaz.font",
  53.     8,0,0
  54. };
  55.  
  56. struct MyListNode
  57. {
  58.     struct WizardDefaultNode WNode;
  59.     char Name[256];
  60. };
  61.  
  62. struct MinList MyList;
  63.  
  64. BOOL CreateNode(char *name,UWORD Pen,UWORD SPen)
  65. {
  66.     BOOL Flag=FALSE;
  67.  
  68.     struct MyListNode *NewNode;
  69.  
  70.     if (NewNode=AllocVec(sizeof(MyListNode),MEMF_CLEAR|MEMF_PUBLIC))
  71.     {
  72.         Flag=TRUE;
  73.  
  74.         WZ_InitNode(&NewNode->WNode.WizardNode,1,TAG_DONE);
  75.  
  76.         strcpy(NewNode->Name,name);
  77.  
  78.         WZ_InitNodeEntry(&NewNode->WNode.WizardNode,0,WENTRYA_Type,WNE_TEXT,
  79.                                                                                 WENTRYA_TextPen,WZRD_TEXTPEN,
  80.                                                                                 WENTRYA_TextSPen,WZRD_FILLTEXTPEN,
  81.                                                                                 WENTRYA_TextString,NewNode->Name,
  82.                                                                                 TAG_DONE);
  83.  
  84.  
  85.         AddTail((struct List *)&MyList,(struct Node *)NewNode);
  86.     }
  87.  
  88.     return(Flag);
  89. }
  90.  
  91. main()
  92. {
  93.     BOOL Flag=FALSE;
  94.  
  95.     struct IntuiMessage *msg;
  96.  
  97.     NewList((struct List *)&MyList);
  98.  
  99.     if (UtilityBase=OpenLibrary("utility.library",0L))
  100.     {
  101.         if (WizardBase=OpenLibrary("wizard.library",0L))
  102.         {
  103.             if (ColorWheelBase=OpenLibrary("gadgets/colorwheel.gadget",0L))
  104.                 {
  105.                     if (MySurface=WZ_OpenSurface("palette.wizard",0,TAG_DONE))
  106.                     {
  107.                         if (MyScreen=OpenScreenTags(0L,SA_LikeWorkbench,TRUE,
  108.                                                                                         SA_Width,640,
  109.                                                                                         SA_Height,304,
  110.                                                                                         SA_Depth,8,
  111.                                                                                         SA_SharePens,TRUE,
  112.                                                                                         SA_Font,&MyTextAttr,
  113.                                                                                         SA_Title,"Palette Preferences",
  114.                                                                                         TAG_DONE))
  115.                         {
  116.                             ULONG RGBValues[3*4];
  117.  
  118.                             GetRGB32(MyScreen->ViewPort.ColorMap,252,4,(ULONG *)&RGBValues);
  119.  
  120.                             SetRGB32(&MyScreen->ViewPort,4,RGBValues[0],RGBValues[1],RGBValues[2]);
  121.                             SetRGB32(&MyScreen->ViewPort,5,RGBValues[3],RGBValues[4],RGBValues[5]);
  122.                             SetRGB32(&MyScreen->ViewPort,6,RGBValues[6],RGBValues[7],RGBValues[8]);
  123.                             SetRGB32(&MyScreen->ViewPort,7,RGBValues[9],RGBValues[10],RGBValues[11]);
  124.  
  125.  
  126.                             if (MyDrInfo=GetScreenDrawInfo(MyScreen))
  127.                             {
  128.                                 if (MyColorWheel=NewObject(0L,"colorwheel.gadget",
  129.                                                                                             GA_ID,50,
  130.  
  131.                                                                                             GA_Left,95,
  132.                                                                                             GA_Top,41,
  133.                                                                                             GA_Width,141,
  134.                                                                                             GA_Height,85,
  135.  
  136.                                                                                             GA_DrawInfo,MyDrInfo,
  137.                                                                                             WHEEL_Screen,MyScreen,
  138.                                                                                             TAG_DONE))
  139.                                 {
  140.                                     if (MyWinHandle=WZ_AllocWindowHandle(MyScreen,0,MySurface,TAG_DONE))
  141.                                         {
  142.                                             if (MyNewWindow=WZ_CreateWindowObj(MyWinHandle,1,
  143.                                                                                                 WWH_GadgetArray,&MyGadgets,
  144.                                                                                                 WWH_GadgetArraySize,sizeof(MyGadgets),
  145.                                                                                                 WWH_PreviousGadget,MyColorWheel,
  146.                                                                                                 TAG_DONE))
  147.                                             {
  148.                                                 MyNewWindow->TopEdge=MyScreen->BarHeight;
  149.  
  150.                                                 MyNewWindow->FirstGadget=MyColorWheel;
  151.                                                 /* Wir wollen schließlich unsere eigenen **
  152.                                                 ** Gadgets auch beim Betriebssystem       **
  153.                                                 ** angemeldet wissen !                      */
  154.  
  155.                                                 if (CreateNode("Background",WZRD_BACKGROUNDPEN,WZRD_BACKGROUNDPEN))
  156.                                                     if (CreateNode("Text",WZRD_TEXTPEN,WZRD_TEXTPEN))
  157.                                                         if (CreateNode("Important Text",WZRD_HIGHLIGHTTEXTPEN,WZRD_HIGHLIGHTTEXTPEN))
  158.                                                             if (CreateNode("Bright Edges",WZRD_SHINEPEN,WZRD_SHINEPEN))
  159.                                                                 if (CreateNode("Dark Edges",WZRD_SHADOWPEN,WZRD_SHADOWPEN))
  160.                                                                     if (CreateNode("Active Windowtitle Bars",WZRD_FILLPEN,WZRD_FILLPEN))
  161.                                                                         if (CreateNode("Active Window Titles",WZRD_FILLTEXTPEN,WZRD_FILLTEXTPEN))
  162.                                                                             if (CreateNode("Menu Background",WZRD_BARBLOCKPEN,WZRD_BARBLOCKPEN))
  163.                                                                                 if (CreateNode("Menu Text",WZRD_BARDETAILPEN,WZRD_BARDETAILPEN))
  164.                                                                                     {
  165.                                                                                         SetGadgetAttrs(MyGadgets[19],0L,0L,WLISTVIEWA_List,&MyList,
  166.                                                                                                                                                                 WLISTVIEWA_Top,FALSE,
  167.                                                                                                                                                                 TAG_DONE);
  168.  
  169.                                                                                         if (MyWindow=WZ_OpenWindow(MyWinHandle,MyNewWindow,
  170.                                                                                                 WA_AutoAdjust,TRUE,
  171.                                                                                                 TAG_DONE))
  172.                                                                                         {
  173.                                                                                             do
  174.                                                                                             {
  175.                                                                                                 WaitPort(MyWindow->UserPort); /* Auf CloseWindow warten*/
  176.  
  177.                                                                                                 if (msg=(struct IntuiMessage *)GetMsg(MyWindow->UserPort))
  178.                                                                                                 {
  179.                                                                                                     switch (msg->Class)
  180.                                                                                                     {
  181.                                                                                                         case IDCMP_MENUPICK:
  182.                                                                                                         {
  183.                                                                                                             if (msg->Code==FULLMENUNUM(0,3,-1))
  184.                                                                                                                 Flag=TRUE;
  185.                                                                                                         }
  186.                                                                                                         break;
  187.                                                                                                     }
  188.                                                                                                     ReplyMsg((struct Message *)msg);
  189.                                                                                                 }
  190.                                                                                             } while (Flag!=TRUE);
  191.  
  192.                                                                                             WZ_CloseWindow(MyWinHandle);
  193.                                                                                         }
  194.                                                                                     }
  195.  
  196.  
  197.  
  198.                                                 while (MyList.mlh_Head->mln_Succ)
  199.                                                 {
  200.                                                     struct Node *t=(struct Node*)MyList.mlh_Head;
  201.  
  202.                                                     Remove(t);
  203.                                                     FreeVec((APTR)t)
  204.                                                 }
  205.                                             }
  206.                                             WZ_FreeWindowHandle(MyWinHandle);
  207.                                         }
  208.                                     DisposeObject(MyColorWheel);
  209.                                 }
  210.                                 FreeScreenDrawInfo(MyScreen,MyDrInfo);
  211.                             }
  212.                             CloseScreen(MyScreen);
  213.                         }
  214.  
  215.                         WZ_CloseSurface(MySurface);
  216.                     }
  217.                     CloseLibrary(ColorWheelBase);
  218.                 }
  219.                 CloseLibrary(WizardBase);
  220.             }
  221.             CloseLibrary(UtilityBase);
  222.         }
  223. };